<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

class CreateNewsTable extends Migration
{
    private $table = 'news';

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create($this->table, function (Blueprint $table) {
            $table->increments('id');
            $table->string('title', 100)->comment('新闻标题');
            $table->string('image', 255)->comment('新闻图片');
            $table->string('link', 255)->comment('新闻链接');
            $table->tinyInteger('platform')->default(0)->comment('平台类型，0.全部 1. IOS 2. Android');
            $table->tinyInteger('jump_type')->default(0)->comment('跳转链接类型，默认0 内部跳转 1 外部跳转 2 跳转至其他程序');
            $table->string('app_id', 50)->nullable()->comment('app_id');
            $table->tinyInteger('is_display')->default(1)->comment('展示类型：0.隐藏 1.显示');
            $table->unsignedInteger('sort')->default(0)->comment('显示权重,值越大越靠前');
            $table->timestamps();
        });

        DB::statement("ALTER TABLE `{$this->table}` COMMENT '积分赛记录表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists($this->table);
    }
}
